梦入琼楼寒有月,行过石树冻无烟

CSS 对齐

居中(center)

1
<center><p>Hello,world!</center>

center(text-align)

1
2
3
4
5
6
7
8
<style>
.text {
text-align: center
}
</style>
<body>
<p class="text">Hello,world!</p>
</body>

右(right)

1
2
3
4
5
6
7
8
<style>
.text {
text-align: right
}
</style>
<body>
<p class="text">Hello,world!</p>
</body>
1
2
3
4
5
6
7
8
<style>
.text {
text-align: left
}
</style>
<body>
<p class="text">Hello,world!</p>
</body>

margin(0 auto)

1
2
3
4
5
6
7
8
9
<style>
.dm {
display: block;
margin: 0 auto;
}
</style>
<body>
<img class="dm" src="http://zsdk.org.cn/img/Joint_ZhongShan/Jiang_Xue_Open_Knowledge_Repository.png">
</body>
ID DE FA
center 居中 元素标签
center 居中 text-align
right 居右
left 居左
0 auto 居中 margin
⬅️ Go back